from day01.basecla import BaseClass
from day01.basecla import driver
from selenium.webdriver.common.by import By
from time import sleep
def choose(x):
    if x=='oked':
        print('点击的为确定按钮')
    elif x=='canceled':
        print('点击的为取消按钮')
c=BaseClass()
c.open_browser('http://sahitest.com/demo/confirmTest.htm')
myconfirm=c.location(By.XPATH,'//input[@name="b1"]')
mytext=c.location(By.XPATH,'//input[@name="t1"]')
myconfirm.click()
myalert1=driver.switch_to.alert
print('弹出提示框信息为：',myalert1.text)
myalert1.accept()
t=mytext.get_attribute("value")
choose(t)
sleep(2)
myconfirm.click()
myalert2=driver.switch_to.alert
print('弹出提示框信息为：',myalert2.text)
myalert2.dismiss()
t=mytext.get_attribute("value")
choose(t)
sleep(2)
c.close_browser()